package org.market.domain.strategy.service.rule.tree.factory;

import lombok.*;
import org.market.domain.strategy.model.valobj.RuleLogicCheckTypeVO;
import org.market.domain.strategy.model.valobj.RuleTreeVO;
import org.market.domain.strategy.service.rule.tree.IRuleTreeNode;
import org.market.domain.strategy.service.rule.tree.engine.IDecisionEngine;
import org.market.domain.strategy.service.rule.tree.engine.impl.DecisionEngin;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author: Insight
 * @Description: TODO
 * @Date: 2025/2/25 下午10:07
 * @Version: 1.0
 */
@Service
public class DefaultRuleTreeFactory {
    private final Map<String, IRuleTreeNode> treeNodeGroup;
    public DefaultRuleTreeFactory(Map<String, IRuleTreeNode> treeNodeGroup) {
        this.treeNodeGroup = treeNodeGroup;
    }

    public IDecisionEngine buildRuleTree(RuleTreeVO ruleTreeVO) {
        return new DecisionEngin(treeNodeGroup,ruleTreeVO);
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class StrategyAwardVO {
        private Integer awardId;
        private String awardRuleValue;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class RuleActionEntity {
        private StrategyAwardVO strategyAwardVO;
        private RuleLogicCheckTypeVO ruleLogicCheckType;
    }
}
